import React,{useState} from 'react'

// export const Input = ({val,setVal,addItem}) => {
export const Input = ({addItem}) => {
    const [val,setVal]=useState('1234');
    //! 父组件内val状态更新不用，所以直接将状态写到子组件内，传参给父组件 
    return (
        <div>
            <input value={val} onChange={(e)=>{setVal(e.target.value)}} type='text'/> 
            <button onClick={()=>addItem(val)}>添加</button>
        </div>
    )
}
